package org.jnarcissus;

import org.jbrisk.tests.ExceptionAssert;
import org.jbrisk.tests.IExceptionAssertRunner;

/**
 * Asserts its {@link MonitoredInstanceMethodCall} instance checking for an
 * exception throw.
 * 
 * @author Rafael Ribeiro.
 * 
 * @param <T>
 *            Exception type.
 */
public class MonitoredInstanceMethodCallExceptionAssert<T extends Throwable> extends MonitoredInstanceMethodAssertBase {

	private String expectedExceptionMessage;

	private Class<T> expectedException;

	private IExceptionAssertRunner runner;

	public IExceptionAssertRunner getRunner() {

		return runner;
	}

	public void setRunner(IExceptionAssertRunner runner) {

		this.runner = runner;
	}

	public String getExpectedExceptionMessage() {

		return expectedExceptionMessage;
	}

	public void setExpectedExceptionMessage(String expectedExceptionMessage) {

		this.expectedExceptionMessage = expectedExceptionMessage;
	}

	public Class<T> getExpectedException() {

		return expectedException;
	}

	public void setExpectedExceptionClass(Class<T> expectedException) {

		this.expectedException = expectedException;
	}

	public MonitoredInstanceMethodCallExceptionAssert(MonitoredInstanceMethodCall method) {

		super(method);
	}

	@Override
	void execute() {

		ExceptionAssert.assertException(getExpectedExceptionMessage(), getExpectedException(), getRunner());
	}
}
